package com.fswan.permission.service.impl;

import com.fswan.permission.Account;
import com.fswan.permission.Role;
import com.fswan.permission.Rule;
import com.fswan.permission.service.PermissionService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PermissionServiceImpl implements PermissionService {

    public Map<Integer, Rule> ruleMap = new HashMap<>();
    public Map<Integer, Role> roleMap = new HashMap<>();
    public Map<Integer, Account> accountMap = new HashMap<>();

    @Override
    public void register(Rule rule) {
        ruleMap.put(rule.getRuleId(), rule);
    }

    @Override
    public void register(Role role) {
        roleMap.put(role.getRoleId(), role);
    }

    @Override
    public void register(Account account) {
        accountMap.put(account.getAccountId(), account);
    }

    @Override
    public List<Integer> getRolesByAccount(int accountId) {
        return null;
    }

    @Override
    public List<Integer> getRulesByRole(int... rules) {
        return null;
    }

    @Override
    public Rule getRuleById(int ruleId) {
        return ruleMap.get(ruleId);
    }

    @Override
    public Role getRoleById(int roleId) {
        return roleMap.get(roleId);
    }

    @Override
    public Account getAccountById(int accountId) {
        return accountMap.get(accountId);
    }
}
